Set Variable MYAH_DISABLE_VISTA_RESTART_MANAGER to FALSE
Set Variable MYAH_DISABLE_ROLLBACK to FALSE
Set Variable NATIVE_ROLLBACK to TRUE
Set Variable NATIVE_OVERRIDE_NON_RESTORABLE_PERMISSIONS to FALSE
Set Variable NATIVE_OVERRIDE_PERMISSIONS to FALSE
Set Variable NATIVE_OVERWRITE_OLDER to FALSE
Set Variable NATIVE_OVERWRITE to PROMPT
Set Variable NATIVE_ERROR to PROMPT
Set Variable DELAYUNTIL_APPLYCHANGES to FALSE
Set Variable SILENT to FALSE
Set Variable SAVEDATA to FALSE
Set Variable MYAHLOGO to TRUE
Set Variable MYAH_TIMEOUT to 10
Set Variable MYAH_COMPRESS_INSTALLER_CACHE to TRUE
Set Variable LOADOLDDATA to TRUE
Set Variable ABORTONERROR to TRUE
 
[DEFINE REGION: Check Application Requirements]
Get System Setting 16-bit Color Depth (Medium Colors) into CHECKSYSTEM
if Variable CHECKSYSTEM not Equals TRUE
  MessageBox: $TITLE$ Setup Error, This product requires at least 16-bit Color Depth (Medium Colors).$NEWLINE$$NEWLINE$Setup cannot continue.
  Terminate Installation
end
Get System Setting 800x600 Resolution into CHECKSYSTEM
if Variable CHECKSYSTEM not Equals TRUE
  MessageBox: $TITLE$ Setup Error, This product requires at least 800x600 Resolution.$NEWLINE$$NEWLINE$Setup cannot continue.
  Terminate Installation
end
Get System Setting 512 MB Physical Memory into CHECKSYSTEM
if Variable CHECKSYSTEM not Equals TRUE
  MessageBox: $TITLE$ Setup Error, This product requires at least 512 MB Physical Memory.$NEWLINE$$NEWLINE$Setup cannot continue.
  Terminate Installation
end
Get System Setting Windows XP into CHECKSYSTEM
if Variable CHECKSYSTEM not Equals TRUE
  MessageBox: $TITLE$ Setup Error, This product requires at least Windows XP.$NEWLINE$$NEWLINE$Setup cannot continue.
  Terminate Installation
end
[END REGION]
 
[DEFINE REGION: FORCE32BIT Check]
Get System Setting Windows in 64 bit Mode into ISWIN64
[compiler if Variable FORCE32BIT Equals TRUE]
Set Variable ISWIN64 to FALSE
Set Win32 - Native 32 bit Windows and Windows 32 on Windows 64 (WOW64) - installation mode
[compiler end]
if Variable ISWIN64 Equals TRUE
  Set x64 - Native 64 bit Windows, AMD64 and EM64T Architectures - installation mode
end
[END REGION]
 
[DEFINE REGION: Check/Install Application Pre-Requisites]
 
[DEFINE REGION: Check Application Pre-Requisites]
Comment: Check setup pre-requisites
Set Variable PREREQ to FALSE
Set Variable PRELIST to 
[compiler if Variable BUILDMODE not Equals PATCH]
if Variable NEEDSUPGRADE Equals TRUE
  Set Variable PREREQ to TRUE
  Set Variable PRELIST to $PRELIST$$NEWLINE$Previous Version Uninstallation
end
Include Script: checkmsi31
[compiler end]
[END REGION]
 
[DEFINE REGION: Install Application Pre-Requisites]
Comment: Install setup pre-requisites
if Variable PREREQ not Equals FALSE
  Display Dialog: prereq, wait for dialog to return (modal)
  if Variable WIZARD Equals CANCEL
    Terminate Installation
  end
  Display Dialog: progressprereq, use as progress dialog (non-modal)
  [compiler if Variable BUILDMODE not Equals PATCH]
  if Variable NEEDSUPGRADE Equals TRUE
    Set Variable REMOVEOLD to 
    Set Variable ERROROLD to 
    Install/Remove MSI Package $PRODUCTCODE$[REMOVE=ALL] (get result into variable REMOVEOLD)
    if Variable REMOVEOLD Equals ERROR
      MessageBox: $TITLE$ Setup, Unable to uninstall old version of $TITLE$. Please uninstall it yourself using Control Panel Add-Remove Programs before attempting to install this product.$NEWLINE$$NEWLINE$$ERROROLD$
      Terminate Installation
    end
    if Variable REMOVEOLD Equals REBOOT
      MessageBox: $TITLE$ Setup, Your computer needs to be restarted before $TITLE$ Setup can continue.$NEWLINE$$NEWLINE$Please save your work in all running programs and click OK to restart your computer. Setup will resume once your computer restarts.$NEWLINE$$NEWLINE$If you click CANCEL, setup will exit. You will have to run setup again at a later time to install $TITLE$.
      if Variable REBOOTNOW Equals OK
        Reboot Computer and Resume Setup
      else
        Terminate Installation
      end
    end
    Set Variable MAINTENANCE to FALSE
  end
  [DEFINE WEB MEDIA Microsoft Windows Installer 3.1]
  Include Script: setupmsi31
  [compiler end]
  Hide Dialog
end
[END REGION]
 
[END REGION]
 
 
[DEFINE REGION: Define Setup Globals]
Comment: TO-DO 01: Setup FILEBAG Variable with InstallApp.config Template
Set Variable FILEBAG to 
Define File Bag : #BINARIES#\InstallApp.config, get runtime location of files into variable FILEBAG
 
Comment: Define Setup Components
Define Component: Main
 
Comment: Initialize Setup Globals
Get System Setting Windows NT Kernel (NT4, 2000, XP, 2003, Vista, 2008, 7, 2008 R2, 8, 2012) into ISNT
Get Folder Location System->Profiles Directory into PROGRAMFILES
Get Common Folder Location System->Profiles Directory into COMMONFILES
Get Common Folder Location Start Menu->Start Menu Group into SHORTCUTFILESALL
Get Folder Location Start Menu->Start Menu Group into SHORTCUTFILES
if Variable SHORTCUTFILESALL Equals 
  Set Variable SHORTCUTFILESALL to $SHORTCUTFILES$
end
Get Folder Location System->CD Burning Directory into DESKTOPDIR
Get Folder Location System->Templates Directory into WINDIR
Get Folder Location System->Send To Directory into WINSYSDIR
Get Folder Location System->Windows Directory into QUICKLAUNCHDIR
Get Folder Location Taskbar->Quick Launch Directory into WWWROOTDIR
Comment: TO-DO 02: Set Target Configuration File Name
Set Variable TARGETCONFIG to TestApplication.exe.config
[END REGION]
 
[DEFINE REGION: Setup User Interview]
if Variable MAINTENANCE Equals TRUE
  GoTo Label: Read existing application settings
else
  [compiler if Variable BUILDMODE not Equals PATCH]
  Comment: First Time Install
  Set Variable TARGETDIR to $PROGRAMFILES$\$COMPANY$\$TITLE$
  Set Variable STARTMENU to $TITLE$
  [compiler end]
end
 
label: Welcome Dialog
Display Dialog: welcome, wait for dialog to return (modal)
if Variable WIZARD Equals CANCEL
  GoTo Label: Main Install
end
[compiler if Variable BUILDMODE not Equals PATCH]
label: License Check
Display Dialog: licensecheck, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: Welcome Dialog
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
label: ReadMe Information
Display Dialog: readme, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: License Check
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
label: User Registration
Display Dialog: registration, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: ReadMe Information
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
label: Setup Type
Display Dialog: setuptype, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: User Registration
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
Comment: TO-DO: Customize your minimum setup here
if Variable MINIMUM Equals TRUE
  Deselect Component: Main
else
  if Variable COMPLETE Equals TRUE
    Select Component: Main
  end
end
label: Custom Setup
Display Dialog: componentstree (if variable PERSONALIZED is TRUE), wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: Setup Type
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
label: Destination Directory
Display Dialog: destination, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: Custom Setup
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
label: Start Menu
Display Dialog: startmenu, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: Destination Directory
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
[compiler end]
 
label: Read existing application settings
Comment: TO-DO 03: Read Existing Application Settings
Evaluate Query /configuration/applicationSettings/TestApplication.Properties.Settings/setting[@name='TestSetting']/value on XML file $TARGETDIR$\$TARGETCONFIG$, get result into variable TESTSETTING as type Node Text
if Variable TESTSETTING Equals 
  Set Variable TESTSETTING to Default Setup Value
end
 
if Variable MAINTENANCE Equals TRUE
  GoTo Label: maintenance
end
 
Comment: TO-DO 04: Create a Dialog sequence here to interview user settings
label: Settings Interview
Display Dialog: settings, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  [compiler if Variable BUILDMODE not Equals PATCH]
  GoTo Label: Start Menu
  [compiler else]
  GoTo Label: Welcome Dialog
  [compiler end]
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
 
label: Start Installation
Display Dialog: startinstallation, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: Settings Interview
else
  GoTo Label: Main Install
end
 
label: Maintenance
Comment: Maintenance Install/Uninstall
wizard loop
Display Dialog: maintenance, wait for dialog to return (modal)
Display Dialog: componentstree (if variable MODIFY is TRUE), wait for dialog to return (modal)
Comment: TO-DO 05: Show settings screens in order to review/change configuration file
Display Dialog: settings (if variable REMOVE is FALSE), wait for dialog to return (modal)
Display Dialog: startinstallation, wait for dialog to return (modal)
end
[END REGION]
 
[DEFINE REGION: Process (Un)Installation]
label: Main Install
Comment: Exit Setup if Wizard Loop cancelled
if Variable WIZARD Equals CANCEL
  Terminate Installation
end
Comment: Prepare to install
Set Variable PROGRESSTEXT to Installing $TITLE$
Set Variable SUCCESS to 
Set Variable LASTERROR to 
if Variable ALLUSERS Equals TRUE
  Set Variable SHORTCUTFOLDER to $SHORTCUTFILESALL$\$STARTMENU$
else
  Set Variable SHORTCUTFOLDER to $SHORTCUTFILES$\$STARTMENU$
end
Display Dialog: progress, use as progress dialog (non-modal)
 
Comment: Modify Target System
[DEFINE REGION: Perform Uninstallation]
if Variable REMOVE Equals TRUE
  Comment: Uninstall product
  Comment: TO-DO: Insert any additional uninstall commands here
  Apply Uninstall (get result into variable SUCCESS)
  Set Variable PROGRESS to 100
else
  [END REGION]
  [DEFINE REGION: Perform First Time or Maintenance Installation]
  Comment: Install/Re-Install product
  Create Shortcut $SHORTCUTFOLDER$\Uninstall #TITLE# to $UNINSTALLLINK$
  [OFFLINE CONTENT]
  Install Files #BINARIES#\TestApplication.exe to $TARGETDIR$
  Create Shortcut $SHORTCUTFOLDER$\Test Application to $TARGETDIR$\TestApplication.exe
  [DEFINE WEB MEDIA Main]
  Get Component Main Selection State into Variable SELECTED
  if Variable SELECTED Equals TRUE
    Comment: TO-DO: Insert any additional install commands here
  end
  [compiler if Variable BUILDMODE Equals PATCH]
  Apply Patch (get result into variable SUCCESS)
  [compiler else]
  if Variable ADVERTISE Equals TRUE
    Apply Advertised (get result into variable SUCCESS)
  else
    Apply Install (get result into variable SUCCESS)
  end
  [compiler end]
  if Variable ADVERTISE not Equals TRUE
    if Variable SUCCESS not Equals ERROR
      if Variable SUCCESS not Equals CANCEL
        Comment: TO-DO 06: Replace Patern based Tokens in InstallApp.Config file with new Values
        Set Variable COLLECTION to 
        Read from Text File #READALL\$FILEBAG$\InstallApp.config into Variable COLLECTION
        Replace @@TESTSETTING@@ with $TESTSETTING$ in variable COLLECTION
        Comment: Keep a backup of the existing configuration file
        Set Variable BACKUPSET to 1
        Does File Exist $TARGETDIR$\$BACKUPSET$_$TARGETCONFIG$.bak (get result into variable BACKUPEXISTS)
        while Variable BACKUPEXISTS Equals TRUE loop
          BACKUPSET = $BACKUPSET$ + 1
          Does File Exist $TARGETDIR$\$BACKUPSET$_$TARGETCONFIG$.bak (get result into variable BACKUPEXISTS)
        wend
        Set Variable NATIVE_ENGINE to TRUE
        Move Local Files $TARGETDIR$\$TARGETCONFIG$ to $TARGETDIR$\$BACKUPSET$_$TARGETCONFIG$.bak
        for each Element TEMPLINE in $NEWLINE$ delimited Collection of $COLLECTION$ do
          Write into Text File $TARGETDIR$\$TARGETCONFIG$ from Value $TEMPLINE$ (at end of file)
        next
        Set Variable NATIVE_ENGINE to FALSE
      end
    end
  end
  label: Apply spplication settings
  Set Variable PROGRESS to 100
end
[END REGION]
[END REGION]
 
[DEFINE REGION: Finish Setup]
Comment: End of Installation
Hide Dialog
Display Dialog: finish, wait for dialog to return (modal)
if Variable SILENT Equals FALSE
  if Variable REBOOTCOMPUTER Equals TRUE
    if Variable SUCCESS Equals REBOOT
      Reboot Computer
    end
  end
  if Variable RUNAPP Equals TRUE
    if Variable REMOVE Equals FALSE
      if Variable SUCCESS Equals COMPLETE
        Run Program $TARGETDIR$\TestApplication.exe 
      end
    end
  end
end
[END REGION]
 
